using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;

using BlueFinity.mvNET.CoreObjects;
using mvLibrary.Helpers;
namespace mvLibrary
{
    public partial class ReportForm : Form
    {
        public ReportForm()
        {
            InitializeComponent();
        }
        public ReportForm(string reportName,string reportHeader)
        {
            InitializeComponent();
            if (reportName.EndsWith("pdf"))
            {
                toolStrip1.Visible = false;
            }
            this.reportBrowser.Navigate(reportName);
            this.labelTitle.Text = reportHeader;
            this.Text = reportName;
        }
        private void saveButton_Click(object sender, EventArgs e)
        {
            reportBrowser.ShowSaveAsDialog();
        }

        private void printerButton_Click(object sender, EventArgs e)
        {
            reportBrowser.ShowPrintDialog();
        }

        private void ReportForm_Load(object sender, EventArgs e)
        {
           
        }

        private void ReportForm_FormClosing(object sender, FormClosingEventArgs e)
        {
           string fileName = reportBrowser.Url.AbsolutePath;
           reportBrowser.Dispose();
           this.Dispose();
           try
           {
               File.Delete(fileName);
           }
           catch
           {
              // MessageBox.Show(MessageUtils.GetCannotDeleteReportMessage(fileName), "Error al eliminar reporte", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
           }
        }        
    }
}

